package pl.wroc.uni.ii.puzzle.activity;

import pl.wroc.uni.ii.puzzle.data.Score;
import pl.wroc.uni.ii.puzzle.view.GameView;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class PuzzleActivity extends Activity {
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		startNewGame();
	}
	
	private void startNewGame() {
		
		String hardship = getIntent().getExtras().getString("hardship");

		final GameView gameView = new GameView(this, hardship);
		setContentView(gameView);
		gameView.post(new Runnable() {

			@Override
			public void run() {
				gameView.start();			
			}
		});
	}

	public void endGameWithScore(Score score) {
		
		Intent intent = new Intent(this, PublishScoreActivity.class);
		intent.putExtra("score", score);
		startActivity(intent);
		
		finish();
	}
}